/**
 * 
 */
package info.niwota.web.jetty;

import info.niwota.web.Debug;
import info.niwota.web.ServerApplication;

import java.io.InputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import android.content.Context;
import android.util.Log;

/**
 * @author qiangli
 * 
 */
public class DefaultHandler extends BaseHandler {
	private static final String TAG = "DefaultHandler";
	

	public DefaultHandler(Context ctx) {
		super(ctx);
	}

	@Override
	public boolean handle(String p, HttpServletRequest req, HttpServletResponse res) {
		try {
			long startup = ServerApplication.startupTime;
			if (Debug.DEBUG) {
				Log.d(TAG, "path: " + p +" startupTime: " + startup);
			}
			String[] data = new String[] {""};
			InputStream is = format(ctx, "index.html", data);
			sendContent(res, is, "text/html");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

}
